/**
 * 应用管理
 * @author luguoxiang
 * @date 2023-03-28
 * 开源项目：https://gitee.com/lgx1992/lg-soar 求star！请给我star！请帮我点个star！
 */
import { IConfigSchema } from '@/soar';
import { basePath } from './api';
import { MenuComponent } from '@/types/interface';

const fieldList: IConfigSchema<any>[] = [
  {
    field: 'id',
    label: '客户端id',
    dataType: 'string',
    table: {
      width: 180,
    },
    form: false,
  },
  {
    field: 'name',
    label: '名称',
    dataType: 'string',
    table: {
      width: 180,
      slots: 'name',
    },
    form: {
      rules: true,
    },
  },
  {
    field: 'secret',
    label: '密钥',
    dataType: 'string',
    search: false,
    table: false,
    form: {
      rules: true,
    },
  },
  {
    field: 'homeUrl',
    label: '主页路径',
    dataType: 'string',
    search: false,
    table: false,
    detail: {
      slots: 'homeUrl',
    },
  },
  {
    field: 'logoutNotifyUrl',
    label: '退出登录通知接口',
    dataType: 'string',
    search: false,
    table: false,
    form: false,
  },
  {
    field: 'remark',
    label: '备注',
    dataType: 'string',
  },
  {
    field: 'onlineCount',
    label: '上线次数',
    dataType: 'number',
    table: {
      width: 100,
    },
  },
  {
    field: 'onlineCountExpire',
    label: '有效期至',
    dataType: 'datetime',
    table: {
      width: 150,
    },
  },
  {
    field: 'onlineId',
    label: '上线标识',
    dataType: 'string',
    search: false,
    table: false,
    form: false,
  },
  {
    field: 'sort',
    label: '排序',
    dataType: 'number',
    table: {
      width: 80,
    },
  },
  {
    field: 'status',
    label: '是否禁用',
    dataType: 'boolean',
    table: {
      width: 100,
    },
  },
];

export default fieldList;

/**
 * 组件配置（用于生成菜单数据）
 */
export const COMPONENTS: MenuComponent[] = [
  {
    title: '应用管理',
    component: () => import('./List.vue'),
    sort: 10,
    keepalive: true,
    icon: 'laptop',
    permits: [`GET${basePath}/query`],
    elements: [
      { title: '新增', code: 'create', permits: [`POST${basePath}/create`] },
      { title: '更新', code: 'update', permits: [`POST${basePath}/update`, `GET${basePath}/detail`] },
      { title: '删除', code: 'remove', permits: [`POST${basePath}/remove`] },
      { title: '详情', code: 'detail', permits: [`GET${basePath}/detail`] },
      { title: '导入', code: 'import', permits: [`POST${basePath}/import`] },
      { title: '导出', code: 'export', permits: [`GET${basePath}/export`] },
    ],
  },
];
